/*
 *  POJ1163: Cow Bowling
 */

/*-------- Includes --------*/
#include <iostream>
#include <algorithm>

using namespace std;

/*-------- Defines --------*/


/*-------- Types --------*/


/*-------- Global Variables --------*/
int d[100][100];

/*-------- Function Prototypes --------*/


/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    int N;

    // get input
    cin >> N;

    for (int i = 0; i < N; i++)
        for (int j = 0; j <= i; j++)
            cin >> d[i][j];

    for (int i = N - 2; i >= 0; i--)
        for (int j = 0; j <= i; j++)
            d[i][j] += max(d[i + 1][j], d[i + 1][j + 1]);

    cout << d[0][0] << endl;

    return 0;
}

/*-------- Functions --------*/

